<template>
  <!-- 作废原因 -->
  <el-dialog
    v-el-drag-dialog
    title="作废原因"
    :visible.sync="visible"
    width="50%"
    append-to-body
    @close="reset"
  >
    <el-form ref="dataForm" :model="temp" :rules="rules" label-position="left" label-width="90px">
      <el-form-item label="作废原因:" prop="remark">
        <el-input v-model.trim="temp.remark" type="textarea" :rows="3" maxlength="255" show-word-limit />
      </el-form-item>
    </el-form>
    <div slot="footer" class="dialog-footer">
      <el-button @click="reset">
        关闭
      </el-button>
      <el-button type="primary" @click="present">
        提交
      </el-button>
    </div>
  </el-dialog>
</template>

<script>
  import { } from '@/api'

  export default {
    name: 'cancellation-cause',
    components: {
    },
    data() {
      return {
        visible: false,
        temp: {
          remark: ''
        },
        rules: {
          remark: [{ required: true, message: '请输入作废原因', trigger: 'change' }]
        }
      }
    },
    methods: {
      async open(row) {
        console.log('row', row)
        return new Promise(resolve => {
          this.resolve = resolve
          this.visible = true
        })
      },
      // 提交
      present() {
        console.log('提交')
        this.$refs.dataForm.validate(async(valid) => {
          if (!valid) return
          console.log('作废')
          // 请求作废接口
          // const { status } = await queryEableContractCheck({
          //   templateId: this.row.templateId,
          //   contractId: this.row.contractId
          // })
          // console.log('作废', status)
          if (status === 200) {
            this.$notify({
              title: '提示',
              message: '作废成功!',
              type: 'success',
              duration: 2000
            })
            this.visible = false
            this.$emit('upChange')
          }
        })
      },
      reset() {
        this.visible = false
        this.temp = {
          remark: ''
        }
        this.$nextTick(() => {
          this.$refs.dataForm.clearValidate()
        })
      }
    }
  }
</script>

<style lang="scss" scoped>

</style>
